import request from '@/utils/request'

// 创建答题记录
export function createAnswer(data) {
  return request({
    url: '/exam/answer/create',
    method: 'post',
    data: data
  })
}

// 更新答题记录
export function updateAnswer(data) {
  return request({
    url: '/exam/answer/update',
    method: 'put',
    data: data
  })
}

// 删除答题记录
export function deleteAnswer(id) {
  return request({
    url: '/exam/answer/delete?id=' + id,
    method: 'delete'
  })
}

// 获得答题记录
export function getAnswer(id) {
  return request({
    url: '/exam/answer/get?id=' + id,
    method: 'get'
  })
}

// 获得答题记录分页
export function getAnswerPage(query) {
  return request({
    url: '/exam/answer/page',
    method: 'get',
    params: query
  })
}

// 导出答题记录 Excel
export function exportAnswerExcel(query) {
  return request({
    url: '/exam/answer/export-excel',
    method: 'get',
    params: query,
    responseType: 'blob'
  })
}


//获得答题详情
export function getAnswerByRecordId (recordId, currentSubjectId, nextSubjectType, nextType) {
  let url ='/exam/answer/record/' + recordId + '/answerInfo?'
  if (currentSubjectId !== undefined) {
    url += '&currentSubjectId=' + currentSubjectId
  }
  if (nextSubjectType !== undefined) {
    url += '&nextSubjectType=' + nextSubjectType
  }
  if (nextType !== undefined) {
    url += '&nextType=' + nextType
  }
  return request({
    url: url,
    method: 'get'
  })
}

export function markAnswer (obj) {
  return request({
    url: '/exam/answer/mark',
    method: 'put',
    data: obj
  })
}